import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
import { uniqueId } from 'lodash';

interface User {
  id: string;
  name: string;
  age: number;
  expand: boolean;
  random: number;
}

@Component({
  selector: 'app-normal-scroll',
  templateUrl: './normal-scroll.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NormalScrollComponent implements OnInit {
  data: Array<User>;

  ngOnInit(): void {
    this.initData();
  }

  initData(): void {
    this.data = Array.from({ length: 100 }).map((item, key) => this.initUser(key));
  }

  initUser(key: number): User {
    return { id: uniqueId('uid'), name: `user${key}`, age: 10 + key, expand: false, random: parseInt(`${Math.random() * 100}`, 10) };
  }
}
